import Vue from "vue";
import Vuex from "vuex";
import payoder from "./payorder.js";
import { keyMap } from "../utils/object.js";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    //设计师标签栏
    tabIndex: 0,
    //表现师标签栏
    tabIndexP: 0,
    willUserPhone: "", // 未注册用户名字输入
    willUserCode: "", // 未注册用户验证码输入
    willUserPwd: "", // 未注册用户密码输入
    willUserPwdCheck: "", // 未注册用户密码校验输入
    WilLoginPhone: "", // 即将登录的手机号
    willLoginPwd: "", // 即将登录的密码
    invoiceId: "", // 设计师-个人中心-每一个发票id
    invoiceMoney: "", // 设计师-个人中心-每一个发票价格
    invoiceObj: null, // 设计师填写地址
    editAddrerss: null, // 设计师 申请发票 编辑旧地址
    walletWithdraw: 0, // 表现师 我的钱包 可提现余额
    bankCardObj: null, // 表现师 我的钱包 已经选择银行卡
    allResume: null, // 表现师 -  我的简介 - 首页所有数据
    newExperience: null, // 表现师 - 我的简历 -  新简历编辑
    oldExperience: null, // 表现师 - 我的简历 - 旧简历经验编辑
    resumeSkillInfos: [], // 表现师 - 我的简历 - 我的技能标签数组
    resumeTypesInfos: null, // 表现师 - 我的简历 - 我的空间标签数组
    resumeStylesInfos: [], // 表现师 - 我的简历 - 我的风格标签数组
    isPay: false, // 表现师首页-保证金
    payCashMoney: 0, // 表现师首页-保证金 -需付金额
    orderUid: null, //订单uid-订单详情
    iconUrl: null, //订单状态图-订单详情
    hot: false, //群组消息红点
	hot2: false, //客服红点
    systemHot: false, //系统消息红点
    modifProfile: false, //true表示修改了头像
    groupTitle: "", //群组标题，推送会用到
	nDialog:1,  //第一次进入客服，会弹窗
	chatScroll:'', //聊天室滚动条距离
    // payoder 里面的均以payoder开头，避免变量冲突，又方便使用，请其他使用者统一此方式
    // tips keyMap函数是修改object的属性的函数
    ...keyMap(payoder)(e => `payOrder${e}`)
  },
  mutations: {
    setHot(state, data) {
      state.hot = data;
    },
	serverHot(state, data) {
	  state.hot2 = data;
	},
    setSystemHot(state, data) {
      state.systemHot = data;
    },
    setProfile(state, data) {
      state.modifProfile = data;
    },
    setTabIndex(state, data) {
      state.tabIndex = data;
    },
    setTitle(state, data) {
      state.groupTitle = data;
    },
    setTabIndexP(state, data) {
      state.tabIndexP = data;
    },
    setWillUserPhone(state, data) {
      state.willUserPhone = data;
    },
	setScroll(state, data) {
	  state.chatScroll = data;
	},
    setWillUserCode(state, data) {
      state.willUserCode = data;
    },
    setWillUserPwd(state, data) {
      state.willUserPwd = data;
    },
    setWillUserPwdCheck(state, data) {
      state.willUserPwdCheck = data;
    },
    setWilLoginPhone(state, data) {
      state.WilLoginPhone = data;
    },
    setWillLoginPwd(state, data) {
      state.willLoginPwd = data;
    },
    setInvoiceId(state, data) {
      state.invoiceId = data;
    },
    setInvoiceMoney(state, data) {
      state.invoiceMoney = data;
    },
    setInvoiceObj(state, data) {
      state.invoiceObj = data;
    },
    setEditAddrerss(state, data) {
      state.editAddrerss = data;
    },
    setWalletWithdraw(state, data) {
      state.walletWithdraw = data;
    },
    setBankCardObj(state, data) {
      state.bankCardObj = data;
    },
    setAllResume(state, data) {
      state.allResume = data;
    },
    setNewExperience(state, data) {
      state.newExperience = data;
    },
    setOldExperience(state, data) {
      state.oldExperience = data;
    },
    setResumeSkillInfos(state, data) {
      state.resumeSkillInfos = data;
    },
    setResumeTypesInfos(state, data) {
      state.resumeTypesInfos = data;
    },
    setResumeStylesInfos(state, data) {
      state.resumeStylesInfos = data;
    },
    setorderUid(state, data) {
      state.orderUid = data;
    },
    seticonUrl(state, data) {
      state.iconUrl = data;
    },
    setIsPay(state, data) {
      state.isPay = data;
    },
    setPayCashMoney(state, data) {
      state.payCashMoney = data;
    },
    UPDATE(state, [setKey, setData]) {
      state[setKey] = setData;
    },
	setDialog(state, data) {
	  state.nDialog = data;
	},
  }
});
